package com.example.lanqiaodemo1.JavaTest5;

public class Student {
   private String name;
   private int age;
   private double score;

    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
    public Integer getAge() { return age; }
    public void setAge(Integer age) { this.age = age; }
    public double getScore() { return score; }

    public void setScore(Integer score) throws ScoreException
    {
        if(score<0||score>200)
            throw new ScoreException();
        this.score = score;
    }

    public Student(String name, int age, double score)throws ScoreException {
        if(score<0||score>200)
            throw new ScoreException();
        this.name = name;
        this.age = age;
        this.score = score;
    }
    public Student(){}

    public void print() {
        System.out.println(this.name);
        System.out.println(this.age);
        System.out.println(this.score);
    }

    public static void main(String[] args) {
        try {
            Student student = new Student("张三",20,220);
            Student list = new Student("李四",30,120);
            list.setScore(230);
        } catch (ScoreException e) {
            System.out.println(e.getMessage());
        }
    }
}



